<script type="text/javascript">
function savetable(){
	$.CurrentNavtab.find('#roleform').submit();
	//$.CurrentNavtab.reload();
}
var groleid = "";
$(function(){
	$("#tablerole").find("tbody > tr").bind("click",function(){
		var roleid = $($(this).find("input")[0]).val();
		var rolename = $($(this).find("input")[1]).val();
		if(groleid!=roleid){
			$('#roleform').bjuiajax('doLoad', {url:"${ctx}/menu/menuFromRole?roleid="+roleid, target:"#rolegetmenutree"});
			$('#roleform').bjuiajax('doLoad', {url:"${ctx}/user/userFromRole?roleid="+roleid, target:"#rolegetusertree"});
			$('#rolename1').text("【"+rolename+"】用户");
			$('#rolename2').text("【"+rolename+"】菜单");
			groleid = roleid;
		}
	});
});


</script>
<div class="bjui-pageHeader">
	<form id="pagerForm" data-toggle="ajaxsearch" action="${ctx}/role" method="post">
        <input type="hidden" name="pageSize" value="${page.pageSize!15}">
        <input type="hidden" name="pageCurrent" value="${page.pageCurrent!1}">
        <input type="hidden" name="orderField" value="${page.orderField!"seq"}">
        <input type="hidden" name="orderDirection" value="${page.orderDirection!"asc"}">
        
        <div class="bjui-searchBar">
        	<button type="button" class="btn-green" data-toggle="tableditadd" data-target="#tablerole" data-num="1" data-icon="plus">添加行</button>&nbsp;
            <button type="button" class="btn-blue" onclick="savetable();" data-icon="save">保存修改</button>&nbsp;
            <label>ID：</label><input type="text" value="${id!}" name="id" size="10" />&nbsp;
            <label>名称：</label><input type="text" value="${text!}" name="text" size="8" />&nbsp;
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            <a class="btn btn-orange" href="javascript:;" onclick="$(this).navtab('reloadForm', true)" data-icon="undo">清空查询</a>&nbsp;
            <div class="alert alert-info search-inline"><i class="fa fa-info-circle"></i> 双击行可编辑</div>&nbsp;
            <div class="pull-right">
                
            </div>
        </div>
        
    </form>
</div>
<div class="bjui-pageContent tableContent">
	<div class="col-md-6">
	    <form action="${ctx}/role/save" id="roleform" class="pageForm" data-toggle="validate" method="post">
	        <table id="tablerole" class="table table-bordered table-hover table-striped table-top" data-toggle="tabledit" data-initnum="0">
	            <thead>
	                <tr>
	                    <th data-order-field="id" title="ID"><input type="text" name="id" readonly value="" size="10"></th>
	                    <th data-order-field="name" title="名称"><input type="text" name="text" data-rule="required" value="新角色名称" size="90"></th>
	                	<th title="操作" data-addtool="true" width="100">
	                		<a href="javascript:;" class="btn btn-red row-del" data-confirm-msg="确定要删除该行信息吗？">删除</a>
	                	</th>
	                </tr>
	            </thead>
	            <tbody>
            <%
               if (page.pageData != null){
                  for (role in page.pageData){
            %>
		                		<tr data-id="${role.id!}">
					                <td>${role.id!}</td>
					                <td>${role.text!}</td>
					                <td data-noedit="true">
	                        		 <a href="${ctx}/role/remove?roleid=${role.id!}" class="btn btn-red row-del" data-confirm-msg="确定要删除该行信息吗？">删除</a>
	                    			</td>
					            </tr>
		    <%
		          }
		       }
		    %>
	            </tbody>
	        </table>
	 	</form>
	</div>
	<div class="col-md-3" style="margin-top: 10px;height:92%;">
		<fieldset style="margin-bottom:0px;position: relative;height:100%;">
            <legend id="rolename1">用户</legend>
            	<div id="rolegetusertree" class="bjui-layout" style="height:100%;overflow: auto;">
            		单击表格行显示数据
                </div>
        </fieldset>
	</div>
	<div class="col-md-3" style="margin-top: 10px;height:92%;">
		<fieldset style="margin-bottom:0px;position: relative;height:100%;">
            <legend id="rolename2">菜单</legend>
            	<div id="rolegetmenutree" class="bjui-layout" style="height:100%;overflow: auto;">
            		单击表格行显示数据
                </div>
        </fieldset>
		
	</div>
    <div class="bjui-pageFooter">
		<div class="pages">
			<span>每页&nbsp;</span>
			<div class="selectPagesize">
				<select data-toggle="selectpicker" data-defval="${page.pageSize!}" data-toggle-change="changepagesize" >
		    		<option value="15">15</option>
		        	<option value="30">30</option>
		        	<option value="50">50</option>
		        	<option value="100">100</option>
		    	</select>
			</div>
			<span>&nbsp;条，共 ${page.totalRow!0} 条</span>
		</div>
		<div class="pagination-box" data-toggle="pagination" data-total="${page.totalRow!}" data-page-size="${page.pageSize!15}" data-page-current="${page.pageCurrent!1}">
		</div>
	</div>
</div>